#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=3010;
int T;
int n,m,L,V;
struct q
{
    int d,v,a,c1,c2;
}car[N];
int cs[N],s[N][N],fin[N];
inline int read()
{
    int f=1,x=0;
    char ch=getchar();
    while(ch>'9'||ch<'0')
    {
        f=-f;ch=getchar();
    }
    while(ch<='9'&&ch>='0')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return f*x;
}
inline void write(int x)
{
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    T=read();
    while(T--)
    {
        int csc=0;
        n=read();m=read();L=read();V=read();
        for(int i=1;i<=n;i++) {car[i].d=read(),car[i].v=read(),car[i].a=read();if(car[i].v>V){car[i].c1=car[i].d,car[i].c2=L;}}
        for(int i=1;i<=m;i++) cs[i]=read();
        for(int i=1;i<=m;i++)
            for(int j=1;j<=n;j++)
                if(car[j].c1<=cs[i]&&car[j].c2>=cs[i]) s[i][0]++,s[i][s[i][0]]=j,fin[j]++;
        for(int i=1;i<=n;i++)
            if(fin[j]>0) csc++;
        write(csc);cout<<" ";
        int d=0;
        sort(s,s+m);
        d=csc-s[0][m]+1;
        write(d);cout<<endl;
    }
    return 0;
}
